| Total Complexity | 1 |
| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import {Injectable, Inject} from '@nestjs/common'; |
||
| 5 | |||
| 6 | @Injectable() |
||
| 7 | export class IsMaximumTimeSpentReached implements ISpecification { |
||
| 8 | constructor( |
||
| 9 | @Inject('IEventRepository') |
||
| 10 | private readonly eventRepository: IEventRepository |
||
| 11 | ) {} |
||
| 12 | |||
| 13 | public async isSatisfiedBy(event: Event): Promise<boolean> { |
||
| 14 | const timeSpent = await this.eventRepository.getDayTimeSpentByUser( |
||
| 15 | event.getUser(), |
||
| 16 | event.getDate() |
||
| 17 | ); |
||
| 18 | |||
| 19 | return timeSpent + event.getTime() > Event.MAXIMUM_TIMESPENT_PER_DAY; |
||
| 20 | } |
||
| 22 |